<template>
  <view>
    <view class="gui-padding gui-bg-white">
      <view class=" gui-border-radius gui-text-center">
        <view @click="selectImage">
          <img :src="shopInfo.image" alt="" class="gui-bg-white"
            style="width: 150rpx;height: 150rpx;border-radius: 100rpx;">
        </view>
        <view>
          <view class=" gui-align-items-center gui-margin-top">
            <text class="gui-h4 ">{{shopInfo.shopName}}</text>
          </view>
          <text class=" gui-block gui-margin-top gui-color-gray gui-icons" style="margin-top:20rpx;">&#xe63f;
            {{shopInfo.city}}{{shopInfo.address}}</text>
        </view>
      </view>
    </view>
    <view class="gui-padding gui-bg-white">
      <view class="gui-margin-top gui-h6  gui-color-gray">
        {{shopInfo.description}}
      </view>
    </view>
    <view class="gui-list gui-margin-top gui-padding-x gui-bg-white">
      <view class="gui-list-items" @click="groupJoin">
        <text class="gui-list-icon gui-icons gui-color-red">&#xe687;</text>
        <view class="gui-list-body  gui-border-b">
          <view class="gui-list-title">
            <text class="gui-list-title-text">团队信息</text>
          </view>
        </view>
        <text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
      </view>
      <view class="gui-list-items" @click="noticeManager">
        <text class="gui-list-icon gui-icons gui-color-red">&#xe687;</text>
        <view class="gui-list-body  gui-border-b">
          <view class="gui-list-title">
            <text class="gui-list-title-text">商机管理</text>
          </view>
        </view>
        <text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
      </view>
      <view class="gui-list-items" @click="dateList">
        <text class="gui-list-icon gui-icons gui-color-orange">&#xe624;</text>
        <view class="gui-list-body gui-border-b">
          <view class="gui-list-title">
            <text class="gui-list-title-text">不接单日期设置</text>
          </view>
        </view>
        <text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
      </view>
      <view class="gui-list-items" @click="goSettings">
        <text class="gui-list-icon gui-icons gui-color-yellow">&#xe613;</text>
        <view class="gui-list-body gui-border-b">
          <view class="gui-list-title">
            <text class="gui-list-title-text">账户余额</text>
            <text class="gui-badge gui-bg-red gui-color-white">{{shopInfo.balance}}元</text>
          </view>
        </view>
        <text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
      </view>
    </view>
  </view>
</template>

<script>
  import productListItem from "@/pages/product/product-list-item"
  export default {
    components: {

      productListItem
    },
    data() {
      return {
        shopInfo: {},
        shop_id: ''
      }
    },

    onLoad(e) {

      if (e.id) {
        this.shop_id = e.id;
      }

      this.initData();
    },
    methods: {
      // 选择上传企业图片
      selectImage() {
        var self = this;
        uni.chooseMedia({
          count: 1,
          success(res) {
            res.tempFiles.forEach(x => {
              var userInfo = uni.getStorageSync('userInfo');
              var token = '';
              if (userInfo) {
                token = userInfo.token;
              }

              uni.uploadFile({
                url: uni.gRequest.server + 'file/upload',
                filePath: x.tempFilePath,
                header: {
                  'Authori-zation': token
                },
                name: 'file',
                success(res) {
                  const shortImageDate = JSON.parse(res.data);
                  // console.log(shortImageDate.url);
                  // self.uploadImageList.push(shortImageDate.url)
                  // result.data.image = uni.gRequest.file + result.data.image;
                  self.shopInfo.image = uni.gRequest.file + shortImageDate.fileName

                  uni.gRequest.post("shop", {
                    image: shortImageDate.fileName,
                    id: 6
                  }).then(x => {
                    uni.showToast({
                      title: "上传成功"
                    });
                  });
                },
                fail(err) {
                  console.log('err', err);
                }
              })

            })

          }
        })
      },
      initData() {
        var self = this;
        uni.gRequest.get('shop/' + this.shop_id).then(result => {
          result.data.image = uni.gRequest.file + result.data.image;
          self.shopInfo = result.data;
          console.log('11111', self.shopInfo)

        });
      },
      groupJoin() {
        uni.navigateTo({
          url: '/pages/shop/add'
        })
      },
      noticeManager() {
        uni.navigateTo({
          url: '/pages/order/group_list?id=' + this.shop_id
        })
      },
      dateList() {
        uni.navigateTo({
          url: '/pages/shop/date_list?shop_id=' + this.shop_id
        })
      },
      goSettings() {
        uni.navigateTo({
          url: '/pages/user/balance/balance?id=' + this.shop_id
        })
      }
    }
  }
</script>

<style>

</style>
